package com.example;

import com.example.config.MyRule;
import com.netflix.loadbalancer.IRule;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@EnableEurekaClient
public class ConsumerApplication {

    public static void main(String[] args) {
        SpringApplication.run(ConsumerApplication.class, args);
    }


    @Bean
   @LoadBalanced         //加上了这个注解就表示由ribbon来操作了
    public RestTemplate  restTemplate(){
        return new RestTemplate();
    }

//   往容器中放入一个rule对象,访问任意一个提供者,都是这个算法
    @Bean
    public IRule myRule(){
        return new MyRule();
    }
}
